package middle

import (
	"log"

	"github.com/gin-gonic/gin"
)

// CheckToken 检查 Token
func CheckToken() gin.HandlerFunc {
	return func(c *gin.Context) {
		token := c.Request.Header.Get("Token")
		if token == "" {
			log.Printf("Token not exist, req=%+v\n", c.Request)
			c.AbortWithStatus(401)
			return
		}

		if token != "lexoncloud" {
			c.AbortWithStatus(401)
			return
		}
	}
}
